module test_server_urlencoded

import Bukdu.Server: UrlEncodedScanner, scan
import Base.Test: @test, @test_throws

data = UInt8[0x6a,0x6f,0x62,0x3d,0x70,0x75,0x74,0x25,0x33,0x41,0x25,0x32,0x30,0x69,0x74,0x25,0x32,0x42,0x25,0x44,0x30,0x25,0x42,0x39,0x26,0x6e,0x61,0x6d,0x65,0x3d,0x25,0x32,0x31,0x25,0x32,0x33,0x25,0x32,0x34,0x25,0x32,0x36,0x25,0x32,0x37,0x25,0x32,0x38,0x25,0x32,0x39,0x25,0x32,0x41,0x25,0x32,0x42,0x25,0x32,0x43,0x25,0x32,0x46,0x25,0x33,0x41,0x25,0x33,0x42,0x25,0x33,0x44,0x25,0x33,0x46,0x25,0x34,0x30,0x25,0x35,0x42,0x25,0x35,0x44,0x25,0x32,0x30]

@test data == UInt8.(collect("job=put%3A%20it%2B%D0%B9&name=%21%23%24%26%27%28%29%2A%2B%2C%2F%3A%3B%3D%3F%40%5B%5D%20"))

scanner = UrlEncodedScanner(data)
assoc = scan(scanner)

@test "!#\$&'()*+,/:;=?@[] " == assoc[:name]
@test "put: it+й" == assoc[:job]

end # module test_server_urlencoded
